package chen.huai.jie.spring.xmlconfig;

import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.webapp.WebAppContext;

import java.io.File;

/**
 * 项目启动类
 */
public class JettyServer {

    public static void main(String[] args) throws Exception {
        Server server = new Server();
        File rootDir = new File(JettyServer.class.getResource("/").getPath()).getParentFile().getParentFile();
        String webAppPath = new File(rootDir, "src/main/webapp").getPath();

        // 普通http通道
        SelectChannelConnector selectChannelConnector = new SelectChannelConnector();
        selectChannelConnector.setPort(9080);
        selectChannelConnector.setMaxIdleTime(30000);

        server.setConnectors(new Connector[]{selectChannelConnector});

        new WebAppContext(server, webAppPath, "/xml");
        server.start();
    }
}
